package com.chanzany.decorator;

public class Decorator extends Drink{
    //被装饰者作为装饰者的成员变量
    private Drink src;

    public Decorator(Drink src){
        this.src = src;
    }

    @Override
    public float cost() {
        return super.getPrice()+ src.cost();
    }

    @Override
    public String getDes() {
        return super.getDes() +  " " + super.getPrice() + "&&" + src.getDes();
    }
}

class Chocolate extends Decorator{
    public Chocolate(Drink src) {
        super(src);
        setDes("巧克力");
        setPrice(3.0f);
    }
}
class Milk extends Decorator{
    public Milk(Drink src) {
        super(src);
        setDes("牛奶");
        setPrice(2.0f);
    }
}
class Cookie extends Decorator{
    public Cookie(Drink src) {
        super(src);
        setDes("曲奇");
        setPrice(1.5f);
    }
}

